home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / swtools / mipsABI / examples / before / dirent.c next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  396 b   |  26 lines

  1. /*
  2.  * illustrates use of directory routines
  3.  *
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include <sys/types.h>
  8. #include <sys/dir.h>
  9.  
  10. main ()
  11. {
  12.     DIR *dp;
  13.     struct direct *dep;
  14.  
  15.     if ((dp = opendir (".")) == NULL)
  16.     {
  17.         fprintf (stderr, "cannot open current directory for reading\n");
  18.         exit (1);
  19.     }
  20.  
  21.     while ((dep = readdir (dp)) != NULL)
  22.         (void) printf ("%s\n", dep->d_name);
  23.     closedir (dp);
  24.     return (0);
  25. }
  26.